The technology described herein relates to the processing of graphics, e.g., for display on a display screen.
It is common in graphics processing systems to render objects for display by sub-dividing the surface of each object into a number of similar basic components called “primitives” to allow the graphics processing operations to be more easily carried out. These primitives are usually in the form of simple polygons, such as triangles.
The graphics primitives are usually generated by the applications program interface for the graphics processing system, using the graphics drawing instructions (requests) received from the application (e.g. game) that requires the graphics output.
Each primitive at this stage is usually defined by and represented as a set of vertices. Each vertex for a primitive has associated with it a set of data (such as position, colour, texture and other attributes data) indicating the properties of the primitive at that vertex. This data is then used, for example, when rasterising and rendering the primitives in order to generate the desired output of the graphics processing system. Once primitives and their vertices have been generated and defined, they can be processed by the graphics processing system in order, for example, to display the object that they relate to.
One way to display the surface of an object more accurately and therefore realistically is to increase the number of primitives and vertices used to represent the object. However, this additional information sometimes may not be needed, for example if the object is being viewed from far away or its surface is at a shallow angle to the viewer, such that finer detail in the surface geometry will not be visible in the rendered output even if it is generated (rendered). In such circumstances, it is a waste of processing resources to process a large number of primitives representing the finer detail of the object.
It is possible to represent the surface geometry of objects with larger “patches”, and to then tessellate additional “tessellation primitives” within a patch in the graphics processing pipeline, if required, in order to display a finer level of detail of the object. Such a patch is therefore a graphical entity that represents some or all of an object to be displayed (rendered). Two common patch shapes are triangular and quadrilateral (e.g. square). This process is referred to as “tessellation”, and is present in, for example, modern versions of OpenGL and Direct3D.
FIG. 1 depicts a tessellation stage 10 as implemented in OpenGL and Direct3D, which includes two shader stages 11, 13 and a fixed-function tessellator or primitive generator 12.
The hull shader (using Direct3D terminology) or control shader (using OpenGL terminology) 11 is operable to receive a patch (e.g. from upstream stages of the graphics processing pipeline), and to, inter alia, calculate a “tessellation factor”. The tessellation factor defines the degree of tessellation required, and thus the number of tessellation primitives that will be generated by the tessellation process. The hull or control shader 11 may also modify the patch in some way.
The tessellation factor is passed to the primitive generator 12, which operates to tessellate a patch to the required degree. The primitive generator 12 typically operates on the patch in an abstract 2D parameter space. A patch may, for example, be tessellated into a plurality of triangular tessellation primitives in the parameter space. FIG. 2 shows an example of a triangular patch 14 in a parameter space and FIG. 3 shows an example of a quadrilateral patch 15 in the same parameter space. In both cases, the primitive generator 12 operates to divide up the patch 14,15 into smaller triangular tessellation primitives, where the number of tessellation primitives depends on the tessellation factor. In both cases shown, the tessellation factor is 15. This results in there being 15 tessellation primitives along each edge of the patch 14,15.
The set of tessellation primitives is typically described by a set of tessellation vertex coordinate pairs (U,V) that define locations in the parameter space that represent positions for the vertices of the tessellation primitives. The set of tessellation primitives is also typically described by information defining the connectivity between the vertices (i.e. how the vertices are to be “joined up” to produce the set of tessellation primitives). This connectivity information is calculated by the primitive generator 12.
The domain shader (using Direct3D terminology) or evaluation shader (using OpenGL terminology) 13 receives the output patch from the control shader 11 as well as the tessellation vertex coordinate pairs from the primitive generator 12, and then operates to apply the tessellation vertex coordinate pairs onto the output patch so as to calculate the positions of vertices for the tessellation primitives for the output patch.
A downstream primitive assembly stage 20 assembles the tessellation primitives using the calculated positions from the domain or evaluation shader 13 and the connectivity information from the primitive generator 12, and then passes the assembled tessellation primitives to further downstream stages of the graphics processing pipeline for further processing, such as rasterisation and rendering, etc., in the usual manner.
In one example, each tessellation vertex coordinate pair generated by the primitive generator 12 is represented by 34 bits. However, such a 34 bit representation can be very inefficient, particularly if the primitive generator 12 is implemented as a series of compute-shaders rather than a fixed-function unit. This is because compute-shaders usually require access to memory, and memory accesses are generally made in powers of 2, e.g. 32 bits, 64 bits etc. Thus, such a 34 bit representation would generally need to be expanded to 64 bits before being written to memory, and this can result in a large amount of wasted bandwidth. It may of course be possible simply to reduce the number of bits in the representation used for the tessellation vertex coordinate pairs in this example, but this simplistic approach would inevitably lead to a loss of resolution in the data.
As will be appreciated, in graphics processors, e.g. in portable devices, it is generally desirable to try to reduce the amount of bandwidth and memory required to transfer, store and access data (e.g. data needed to generate an image for display) where possible, but without a corresponding reduction in the resolution of the data.
The Applicants believe that there remains scope for improvements to techniques for processing graphics data, and in particular to arrangements where tessellation is provided and used.
Like reference numerals are used for like components where appropriate in the drawings.